package com.i360day.redis.emuns;

public enum MatchingType {
    CONTAINS,//包含
    EQ,//等于
    STARTWITH,//key开始
    ENDWITH,//key结束
    ;

    /**
     * <p> @Author liju.z <p>
     *
     * <p> @Description 比较 <p>
     *
     * <p> @Date  8:48 <p>
     *
     * <p> @Param [descValue, value] <p>
     *
     * <p> @return [descValue, value] <p>
     **/
    public boolean compare(String descValue, String value) {
        if (descValue == null || descValue.trim() == "") return false;
        else if (value == null || value.trim() == "") return false;
        switch (this) {
            case EQ:
                return descValue.equals(value);
            case CONTAINS:
                return descValue.contains(value);
            case STARTWITH:
                return descValue.startsWith(value);
            case ENDWITH:
                return descValue.endsWith(value);
        }
        return false;
    }
}
